package com.wtgroup.demo.leetcode.q300_最长递增子序列;

/**
 * @author dafei
 * @version 0.1
 * @date 2021/4/15 8:36
 * @deprecated 错误
 */
public class Q300_My {
    public static void main(String[] args) {
        int[][] inputs = {
                {10, 9, 2, 5, 3, 7, 101, 18},
                {0, 1, 0, 3, 2, 3},
                {7, 7, 7, 7, 7, 7, 7},
                {1}
        };
        Q300_My exe = new Q300_My();
        for (int[] input : inputs) {
            int i = exe.lengthOfLIS(input);
            System.out.println(i);
        }
    }


    /**
     * 暴力
     *
     * [错误] 0 3 2 , 后面还有更小的 2 , 分支情况漏了.
     */

    public int lengthOfLIS(int[] nums) {
        int n = nums.length;
        int maxLen = 0;
        for (int i = 0; i < n; i++) {
            int curLen = 1;
            int curMax = nums[i];
            for (int j = i+1; j < n; j++) {
                if (nums[j] > curMax) {
                    curLen++;
                    curMax = nums[j];
                }
            }
            if(curLen>maxLen) maxLen = curLen;
        }

        return maxLen;
    }
}
